package com.bawei.lib_image

import android.graphics.Typeface
import android.widget.ImageView
import android.widget.TextView
import androidx.databinding.BindingAdapter
import com.bumptech.glide.load.resource.bitmap.CircleCrop

/**
 * @author yaotianxue
 * @description
 * @date 2025/5/26
 */
object ImageBindingAdapter {
    @JvmStatic
    @BindingAdapter("avatarUrl")
    fun avatarUrl(imageView:ImageView,url:String){
        GlideApp.with(imageView.context)
            .load(url)
            .transform(CircleCrop())
            .placeholder(R.mipmap.icon_default_avatar)
            .error(R.mipmap.icon_default_avatar)
            .into(imageView)
    }
    @JvmStatic
    @BindingAdapter("textBold")
    fun textBold(textView: TextView, boolean: Boolean) {
        textView.typeface = if (boolean) Typeface.DEFAULT_BOLD else Typeface.DEFAULT
    }
}